package com.lotus.vigil.service;


import com.lotus.vigil.model.DeviceFaultRecords;
import com.lotus.vigil.model.DeviceFaultStats;
import com.lotus.vigil.repository.FaultRecordRepository;
import com.lotus.vigil.service.processor.FaultDataProcessor;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@RequiredArgsConstructor
public class FaultStatsService {
    private final FaultRecordRepository faultRecordRepository;
    public List<DeviceFaultStats> getFaultStats(LocalDateTime startTime, LocalDateTime endTime){
        List<DeviceFaultRecords> deviceFaultRecords = faultRecordRepository.findEventsInRange(startTime, endTime);
        return FaultDataProcessor.process(deviceFaultRecords,endTime);
    }
}
